package jspx.example.interceptor.db;

import com.github.jspxnet.sioc.annotation.Bean;
import com.github.jspxnet.sober.Interceptor;
import com.github.jspxnet.sober.SoberSupport;
import com.github.jspxnet.utils.ObjectUtil;
import jspx.example.env.DemoIoc;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;
/**
 * sql map 查询拦截器,根据 配置 的 term 条件的拦截,政策表达式匹配 查询 name
 *
 */
@Slf4j
@Bean(bind = TermDemoInterceptor.class,namespace = DemoIoc.namespace)
public class TermDemoInterceptor  implements Interceptor {
    @Override
    public void init() {


        log.debug("-------TermDemoInterceptor init");
    }

    @Override
    public void before(SoberSupport soberSupport, Map<String, Object> valueMap) throws Exception
    {
        log.debug("-------TermDemoInterceptor before =" + ObjectUtil.toString(valueMap));
        valueMap.put("test","AAAA");
    }

    @Override
    public Object after(SoberSupport soberSupport, Map<String, Object> valueMap, Object result) throws Exception {
        log.debug("-------TermDemoInterceptor after =" + ObjectUtil.toString(result));
        return result;
    }

    @Override
    public void destroy() {
        log.debug("-------TermDemoInterceptor destroy");
    }

}
